package com.wlyuan.open.scanner.utils.enums.transport;

import com.wlyuan.core.marker.NamedValue;
import com.wlyuan.core.marker.NamedValueMap;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author lijing
 * @description 运单关闭类型新老系统关系
 */
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
@Getter
public enum TransportCloseStatusEnum implements NamedValue<Integer> {

    SERVICE_START(1, 20, "客服发起关闭订单"),
    OPERATION_START(2, 20, "运营发起关闭订单"),
    SERVICE_CLOSE_REQUEST(3, 20, "运营关闭订单通知"),
    OPERATION_CLOSE_NOTIFY(4, 20, "客服关闭订单通知"),
    SERVICE_CLOSE_NOTIFY(5, 20, "客服发起拼车单关闭订单"),
    REJECT_CLOSE(6, 60, "已关闭订单"),
    SERVICE_CLOSED(7, 20, "运营发起拼车单关闭订单"),
    OPERATION_CLOSED(8, 20, "本方客服关闭订单通知"),
    ;

    private final Integer value;
    private final Integer newValue;
    private final String name;

    private static final Map<Integer, TransportCloseStatusEnum> MAP = new NamedValueMap<>(TransportCloseStatusEnum.class);

    public static TransportCloseStatusEnum fromValue(Integer value) {
        return MAP.get(value);
    }

    public static boolean closeIng(Integer val) {
        return MAP.keySet().stream().filter(x -> !REJECT_CLOSE.getValue().equals(x)).collect(Collectors.toList()).contains(val);
    }

}
